#include "uart.h"

void uart0_init(uint32_t buadrate)
{
    uart_config_t uart0_init_struct={0};
    uart0_init_struct.baud_rate=buadrate;
    uart0_init_struct.data_bits=UART_DATA_8_BITS;
    uart0_init_struct.parity=UART_PARITY_DISABLE;
    uart0_init_struct.stop_bits=UART_STOP_BITS_1;
    uart0_init_struct.flow_ctrl=UART_HW_FLOWCTRL_DISABLE;
    uart0_init_struct.source_clk=UART_SCLK_DEFAULT;


    ESP_ERROR_CHECK(uart_param_config(UART_UX,&uart0_init_struct));
    ESP_ERROR_CHECK(uart_set_pin(UART_UX,
                                UART_TX_GPIO_PIN,
                                UART_RX_GPIO_PIN,
                                UART_PIN_NO_CHANGE,
                                UART_PIN_NO_CHANGE));
    ESP_ERROR_CHECK(uart_driver_install(UART_UX,UART_BUFFER_SIZE,
                                        UART_BUFFER_SIZE,0,NULL,0));
}